#define _CRT_SECURE_NO_WARNINGS
#include"list.h"
#include<iostream>

struct A
{
	A(int a1 = 0, int a2 = 0)
		:_a1(a1)
		, _a2(a2)
	{}

	int _a1;
	int _a2;
};
void print(const my_list::list<int>& l)
{
	my_list::list<int>::const_iterator it = l.begin();
	while (it != l.end())
	{
		//(*it)++;
		std::cout << *it << std::endl;
		++it;
	}
}

void print2(const my_list::list<A> &lt)
{
	my_list::list<A>::const_iterator it = lt.begin();
	while (it != lt.end())
	{
		//cout << (*it)._a1 << " " << (*it)._a2 << endl;
		std::cout << it->_a1 << " " << it->_a2 << std::endl;

		++it;
	}
	std::cout << std::endl;
}

void List_test()
{
	 my_list::list<int> l;
	l.push_back(1);
	l.push_back(2);
	l.push_back(3);
	my_list::list<int>::iterator it = l.begin();
	print(l);
	while (it != l.end())
	{
		std::cout << *it << std::endl;
		//std::cout <<  << std::endl;
		++it;
	}
}




void test_List2()
{
		my_list::list<A> lt;
		lt.push_back(A(1, 1));
		lt.push_back(A(2, 2));
		lt.push_back(A(3, 3));
		lt.push_back(A(4, 4));

		//my_list::list<A>::iterator it = lt.begin();
		print2(lt);
		//while (it != lt.end())
		//{
		//	//cout << (*it)._a1 << " " << (*it)._a2 << endl;
		//	std::cout << it->_a1 << " " << it->_a2 << std::endl;

		//	++it;
		//}
	std::cout << std :: endl;

}

void test_List3()
{
	my_list::list<int> l;
	l.push_back(1);
	l.push_back(2);
	l.push_back(3);
	l.push_back(4);
	l.push_back(5);
	l.push_front(111);
	
	my_list::list<int>::iterator it = l.begin();

	while (it != l.end())
	{
		std::cout << *it << std::endl;
		//std::cout <<  << std::endl;
		++it;
	}
	std::cout <<  std::endl;

	l.clear();
	l.push_back(4);
	l.push_back(5);

	my_list::list<int>::iterator it2 = l.begin();
	while (it2 != l.end())
	{
		std::cout << *it2 << std::endl;
		//std::cout <<  << std::endl;
		++it2;
	}

	my_list::list<int> l2(l);
	my_list::list<int>::iterator it3 = ++l2.begin();

	while (it3 != l2.end())
	{
		std::cout << *it3 << std::endl;
		//std::cout <<  << std::endl;
		++it3;
	}
}



int main()
{
	test_List3();
	return 0;
}


